//
//  TLNewAboutMeViewController.m
//  WXReader
//
//  Created by huaya on 2025/8/24.
//  Copyright © 2025 Andrew. All rights reserved.
//

#import "TLNewAboutMeViewController.h"
#import "TL_WebViewViewController.h"
@interface TLNewAboutMeViewController ()
@property (nonatomic, strong) UIView *navView;
@property (nonatomic, strong) UILabel *navTitleLab;
@property (nonatomic, strong) UIButton *backBtn;
@property (nonatomic, strong) UIScrollView *scrollView;
@end

@implementation TLNewAboutMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setUI];
    
}
- (void)setUI{
    
    [self.view addSubview:self.navView];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,  CGRectGetMaxY(self.navView.frame), kScreenWidth, kScreenHeight-CGRectGetMaxY(self.navView.frame))];
    
    [self.scrollView setBackgroundColor:[UIColor hex_F8F8F8]];
    
    [self.view addSubview:self.scrollView];
    
    UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_12"]];
    
    imgView.frame = CGRectMake(kScreenWidth/2-84/2, 40, 84, 84);
    
    [self.scrollView addSubview:imgView];
    
    UILabel *appLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imgView.frame)+20, kScreenWidth, 33)];
    appLab.text = App_Name;
    appLab.textColor = [UIColor hex_333333];
    appLab.font = SYSTEM_FONT(24);
    appLab.textAlignment = NSTextAlignmentCenter;
    [self.scrollView addSubview:appLab];
    
    UILabel *appVersionLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(appLab.frame), kScreenWidth, 17)];
    appVersionLab.text = [NSString stringWithFormat:@"Version %@",App_Ver];
    appVersionLab.textColor = [UIColor hex_999999];
    appVersionLab.font = SYSTEM_FONT(12);
    appVersionLab.textAlignment = NSTextAlignmentCenter;
    [self.scrollView addSubview:appVersionLab];
    
    UIView *tosView = [[UIView alloc] initWithFrame:CGRectMake(16, CGRectGetMaxY(appVersionLab.frame)+40, kScreenWidth-32, 56)];
    [tosView setBackgroundColor:[UIColor whiteColor]];
    
    [tosView addRoundingCornersWithRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight andCornerRadii:8];
    
    UILabel *tosLab = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, 200, 56)];
    tosLab.text = @"Terms of Service";
    tosLab.textColor = [UIColor hex_333333];
    tosLab.font = SYSTEM_FONT(14);
    [tosView addSubview:tosLab];
    
    UIImageView *tosMoreView = [[UIImageView alloc] initWithFrame:CGRectMake((tosView.frame.size.width-6-16), (56-11)/2, 6, 11)];
    tosMoreView.image = [UIImage imageNamed:@"xq-xfzj-fh_y"];
    [tosView addSubview:tosMoreView];
    
    [self.scrollView addSubview:tosView];
    MJWeakSelf
    UITapGestureRecognizer *tosTapGest = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        
        TL_WebViewViewController *vc = [[TL_WebViewViewController alloc] init];
        vc.isPresentState = NO;
        vc.navTitle = WXLocalizedString(@"用户协议");
        vc.URLString = [NSString stringWithFormat:@"%@",[APIURLManager AgreementURL]];
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    [tosView addGestureRecognizer:tosTapGest];
    
    
    UIView *ppView = [[UIView alloc] initWithFrame:CGRectMake(16, CGRectGetMaxY(tosView.frame), kScreenWidth-32, 56)];
    [ppView setBackgroundColor:[UIColor whiteColor]];
    
    [ppView addRoundingCornersWithRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight andCornerRadii:8];
    
    UILabel *ppLab = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, 200, 56)];
    ppLab.text = @"Privacy Policy";
    ppLab.textColor = [UIColor hex_333333];
    ppLab.font = SYSTEM_FONT(14);
    [ppView addSubview:ppLab];
    
    UIImageView *ppMoreView = [[UIImageView alloc] initWithFrame:CGRectMake((tosView.frame.size.width-6-16), (56-11)/2, 6, 11)];
    ppMoreView.image = [UIImage imageNamed:@"xq-xfzj-fh_y"];
    [ppView addSubview:ppMoreView];
    
    [self.scrollView addSubview:ppView];
    UITapGestureRecognizer *ppTapGest = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
        
        TL_WebViewViewController *vc = [[TL_WebViewViewController alloc] init];
        vc.isPresentState = NO;
        vc.navTitle = WXLocalizedString(@"隐私政策");
        vc.URLString = [NSString stringWithFormat:@"%@",[APIURLManager PrivacyURL]];
        [weakSelf.navigationController pushViewController:vc animated:YES];
    }];
    [ppView addGestureRecognizer:ppTapGest];
    
    UILabel *copyRightLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(self.scrollView.frame)-45-17, kScreenWidth, 17)];
    copyRightLab.text = [NSString stringWithFormat:@"Copyright © %@. All Rights Reserved",App_Name];
    copyRightLab.textColor = [UIColor hex_9E6DFC];
    copyRightLab.font = SYSTEM_FONT(12);
    copyRightLab.textAlignment = NSTextAlignmentCenter;
    [self.scrollView addSubview:copyRightLab];
    
    
}



- (UIView *)navView{
    if (!_navView) {
        _navView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, PUB_NAVBAR_HEIGHT)];
        [_navView setBackgroundColor:[UIColor whiteColor]];
        _backBtn = [[UIButton alloc] initWithFrame:CGRectMake(6, PUB_NAVBAR_HEIGHT - 28 - 6, 28, 28)];
        [_backBtn setImage:[UIImage imageNamed:@"tzxqy_fh"] forState:UIControlStateNormal];
        [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
        
        [_navView addSubview:_backBtn];
        
        _navTitleLab = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_backBtn.frame)+10, PUB_NAVBAR_HEIGHT - 28 - 6, kScreenWidth-2*(CGRectGetMaxX(_backBtn.frame)+10), 28)];
        _navTitleLab.text = WXLocalizedString(@"关于我们");
        _navTitleLab.textColor = [UIColor hex_333333];
        _navTitleLab.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
        _navTitleLab.textAlignment = NSTextAlignmentCenter;
        [_navView addSubview:_navTitleLab];
        
    }
    return _navView;
}
- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}

@end
